package com.beauty.dressing.module.community.holder;

import android.content.Context;
import android.graphics.Color;
import android.text.Html;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.beauty.dressing.R;
import com.beauty.dressing.common.base.BaseRecyclerViewHolder;
import com.beauty.dressing.common.bean.Ad;
import com.beauty.dressing.common.bean.Post;
import com.beauty.dressing.common.view.NoScrollGridView;
import com.beauty.dressing.module.common.view.PraiseArea;
import com.beauty.dressing.module.common.view.ReplyArea;
import com.beauty.dressing.module.community.activity.PostDetailActivity;
import com.beauty.dressing.module.community.adapter.ImageAdapter;
import com.facebook.drawee.view.SimpleDraweeView;
import com.framework.common.utils.ICommonUtil;
import com.xiaolanba.commonlib.fresco.FrescoUtil;

import java.util.ArrayList;
import java.util.List;

import static android.view.View.GONE;
import static android.view.View.VISIBLE;

/**
 * 帖子
 * @author Angus
 * @company 9zhitx.com
 */
public class PostsViewHolder extends BaseRecyclerViewHolder<Post> implements View.OnClickListener {
    private SimpleDraweeView mHeaderImg;
    //3.2达人V标识
    private ImageView mTalentVImg;
    private Post dynamic;
    private TextView mPraiseNumTxt;
    private ImageView mPraiseImg;
    private View mHeadLayout, mNameLayout;
private NoScrollGridView imgsGv;
    private boolean isWifiAutoLoadGif;
    ReplyArea commentArea;
    PraiseArea praiseArea;
    View mBottomSpace;
    boolean needOnClick = true;
    public void setNeedOnClick(boolean flag){
        needOnClick = flag;
    }
    public PostsViewHolder(Context mContext, LayoutInflater mInflater, ViewGroup viewGroup) {
        super(R.layout.common_post_dynamic, mContext, mInflater, viewGroup);
    }

    @Override
    public void findView() {
        mHeaderImg = (SimpleDraweeView) itemView.findViewById(R.id.header_cimg);
        imgsGv = (NoScrollGridView) itemView.findViewById(R.id.imgs_ngv);
        commentArea = itemView.findViewById(R.id.comment_area);
        praiseArea = itemView.findViewById(R.id.praise_area);
        mBottomSpace = itemView.findViewById(R.id.bottom_space_view);
    }

    @Override
    public void bindData(Post dynamic, int position) {
        if (needOnClick) {
            registerItemClick(dynamic, position);
        } else {
            mBottomSpace.setVisibility(View.GONE);
        }
        ArrayList<String> imageList = new ArrayList<>();
        imageList.add("https://tvax2.sinaimg.cn/crop.0.0.664.664.180/006zWmitly8fgxj1jcsevj30ig0igt9h.jpg");
        imageList.add("https://tvax2.sinaimg.cn/crop.0.0.664.664.180/006zWmitly8fgxj1jcsevj30ig0igt9h.jpg");
        imageList.add("https://tvax2.sinaimg.cn/crop.0.0.664.664.180/006zWmitly8fgxj1jcsevj30ig0igt9h.jpg");
        FrescoUtil.loadImage(mHeaderImg,"https://tvax2.sinaimg.cn/crop.0.0.664.664.180/006zWmitly8fgxj1jcsevj30ig0igt9h.jpg");
        imgsGv.setVisibility(View.VISIBLE);
        imgsGv.setAdapter(new ImageAdapter(imageList,null,mContext));
        praiseArea.setPraiseNum(11);
        commentArea.setCommentNum(15);
    }


    @Override
    public void onItemClick(Post bean, int position) {
        PostDetailActivity.startActivity(mContext);
    }

    public void setPraiseLayout(Post dynamic){
    }


    @Override
    public void onClick(View v) {
        if (ICommonUtil.isFastDoubleClick()){
            return;
        }
        switch (v.getId()) {
            case R.id.header_cimg:
            case R.id.name_txt:
                break;
        }
    }
}
